<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>

// This tests deleting selections that contains cells in a table
// should or should not remove a row appropriately.

selection_test(
    [
        '<div contenteditable>',
            '<table><tbody>',
                '<tr><td>1</td><td>^2</td><td>3</td></tr>',
                '<tr><td>4</td><td>5</td><td>6</td></tr>',
                '<tr><td>7</td><td>8|</td><td>9</td></tr>',
            '</tbody></table>',
        '</div>'
    ],
    "Delete",
    [
        '<div contenteditable>',
            '<table><tbody>',
                '<tr><td>1</td><td>|<br></td><td></td></tr>',
                '<tr><td></td><td></td><td>9</td></tr>',
            '</tbody></table>',
        '</div>'
    ],
    'Empties the second row which should be removed');

selection_test(
    [
        '<div contenteditable>',
            '<table><tbody>',
                '<tr><td>1</td><td>2</td><td>3</td></tr>',
                '<tr><td>^4</td><td>5</td><td>6|</td></tr>',
                '<tr><td>7</td><td>8</td><td>9</td></tr>',
            '</tbody></table>',
        '</div>'
    ],
    "Delete",
    [
        '<div contenteditable>',
            '<table><tbody>',
                '<tr><td>1</td><td>2</td><td>3</td></tr>',
                '<tr><td>|<br></td><td></td><td><br></td></tr>',
                '<tr><td>7</td><td>8</td><td>9</td></tr>',
            '</tbody></table>',
        '</div>'
    ],
    'Empties the second row which should NOT be removed because contains the selection');

selection_test(
    [
        '<div contenteditable>',
            '<div>Hello,^world</div>',
            '<table><tbody>',
                '<tr><td>1</td><td>2</td><td>3</td></tr>',
                '<tr><td>4</td><td>5|</td><td>6</td></tr>',
                '<tr><td>7</td><td>8</td><td>9</td></tr>',
            '</tbody></table>',
        '</div>'
    ],
    "Delete",
    [
        '<div contenteditable>',
            '<div>Hello,|</div>',
            '<table><tbody>',
                '<tr><td></td><td></td><td>6</td></tr>',
                '<tr><td>7</td><td>8</td><td>9</td></tr>',
            '</tbody></table>',
        '</div>'
    ],
    'Empties the first row which should be removed');
</script>
